class Solution {
    public int countBeautifulPairs(int[] nums) {
        int count = 0;
        for(int i = 0; i < nums.length - 1; i++){
            while(nums[i]/10 !=0){
                nums[i] /= 10;
            }
            for(int j = i+1; j < nums.length; j++){
                int b = nums[j]%10;
                if(gcd(nums[i],b)==1){
                    count++;
                }
            }
        }
        return count;
    }
    public int gcd(int a, int b){
        int c = a%b;
        while(c != 0){
            a = b;
            b = c;
            c = a%b;
        }
        return b;
    }
}
class Solution {
    public int makeTheIntegerZero(int num1, int num2) {
        //x = num1 -num2*k
        //k [x.bit_count,x]
        for(long k = 1; k <= num1 - num2 * k ; k++){
            if(k >= bitCount(num1 - num2 * k))
                return (int)k;
        }
        return -1;
    }

    public long bitCount(long x){
        long count = 0;
        while(x != 0){
            x = x&(x-1);
            count++;
        }
        return count;
    }
}
class Solution {
    public int numberOfGoodSubarraySplits(int[] nums) {
        int MOD = (int)1e9+7;
        long sum = 1;
        int flag = 0;
        for(int i=0; i<nums.length; i++){
            if(nums[i] == 1){
                flag = 1;
                for(int j=i+1; j<nums.length; j++){
                    if(nums[j] == 1){
                        sum = sum*(j-i)%MOD;
                        i = j;
                    }
                }
            }
        }
        if(flag == 0){
            return 0;
        }
        return (int)sum;
    }
}

public class Test {
}
